# -*- coding:utf-8 -*-
from django.dispatch import Signal,receiver
from django.db.models.signals import pre_save,post_save

signalfoo = Signal(providing_args=['foo']) #实例化

@receiver(signalfoo)
def signal_callback(sender,**kwargs): #信号回调函数
	print sender,kwargs
	print 'signal_callback called'

@receiver(signalfoo)
def signal_callback1(sender,**kwargs): #信号回调函数
	print sender,kwargs
	print 'signal_callback1 called'

# signalfoo.connect(signal_callback) #将信号回调函数注册到实例里
# signalfoo.connect(signal_callback1)

@receiver(pre_save)
def pre_save_callback(sender,**kwargs):
	print 'pre_save_callback'

@receiver(post_save)
def post_save_callback(sender,**kwargs):
	print 'post_save_callback'